# -*- coding: utf-8 -*-

from classic.linkedlist import SingleLinkedList

def solution(strs):
    abcba = SingleLinkedList(*strs)
    l = abcba.length
    front, back = abcba.slice(0, l//2-1), abcba.slice(l//2+l%2, l-1)
    ispalin = True
    for n in back:
        f = front.pop()
        if n != f:
            ispalin = False
            break
    if ispalin:
        print('\'%s\'是回文字符串' % strs)
    else:
        print('\'%s\'不是回文字符串' % strs)


if __name__ == '__main__':
    solution('abcbac')
    solution('abcba')
    solution('aa')
    solution('   ')
    solution('a')
